package com.huika.dealontop.utils;

import android.content.Context;
import android.view.View;

import com.huika.dealontop.views.IOSAlertDialog;

/**
 * Author: Victor Wu
 * Email: victor-wu*foxmail.com
 * Time: 2015/11/18 15:43
 * Description: 对话框工具类
 */
public class DialogUtils {
    private IOSAlertDialog dialog;

    private static DialogUtils dialogUtils;

    public static DialogUtils getInstance() {
        if (null == dialogUtils) {
            dialogUtils = new DialogUtils();
        }
        return dialogUtils;
    }

    public IOSAlertDialog createNormDialog(Context mContext) {
        cleanLastDialog();
        dialog = new IOSAlertDialog(mContext);
        return dialog;
    }

    public IOSAlertDialog createTitleDialog(Context mContext, String title) {
        cleanLastDialog();
        dialog = new IOSAlertDialog(mContext).setTitleText(title);
        return dialog;
    }

    public IOSAlertDialog createContentTextDialog(Context mContext, String title, String msg) {
        cleanLastDialog();
        dialog = new IOSAlertDialog(mContext).setTitleText(title).setContentText(msg);
        return dialog;
    }

    public IOSAlertDialog createCustomViewDialog(Context mContext, View customView) {
        cleanLastDialog();
        dialog = new IOSAlertDialog(mContext).setCustomView(customView);
        return dialog;
    }

    private void cleanLastDialog() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
            dialog = null;
        }
    }


}
